#pragma once

typedef enum{
		EOBJTYPE_WATER=0,
		EOBJTYPE_FOOD=1,
		EOBJTYPE_CREATURE=2
}EOBJTYPE;

typedef enum{
	DIR_LEFT_UP,
	DIR_UP,
	DIR_RIGHT_UP,
	DIR_LEFT,
	DIR_RIGHT,
	DIR_LEFT_DOWN,
	DIR_DOWN,
	DIR_RIGHT_DOWN,
	DIR_NONE,
}DIRECTION;

typedef enum{
		RES_COMMON,
		RES_GOOD,
		RES_BAD,
}RESULT_JUDGMENT;


#define INPUT_SIGNAL_COUNT 3
#define OUTPUT_SIGNAL_COUNT 4

//#define NERVUS_EXCITE_LEVEL 5
//#define NERVUS_EXCITE_PERIOD NERVUS_EXCITE_LEVEL
//#define NERVUS_NO_RESPONSE_PERIOD (NERVUS_EXCITE_LEVEL+3)

#define NERVUS_MAP_WIDTH 4
#define NERVUS_MAP_DEPTH 6

#define ALL_DIRECTION_COUNT 8

#define NERVUS_ANTENNA_NUM 3

#define MAX_CASE ((int) pow( (float)INPUT_SIGNAL_COUNT , ALL_DIRECTION_COUNT))
#define MAX_RUN_STEP (ALL_DIRECTION_COUNT*2+NERVUS_MAP_WIDTH*NERVUS_MAP_DEPTH)


class Complex
{
public:
    double real;
    double image;
    
    Complex(double r=0, double i=0){real = r, image = i;}

	Complex operator+(const Complex &b)
	{
		Complex c;
		c.real = real + b.real;
		c.image = image + b.image;
		return c;
	};

	Complex operator*(const Complex &b)
	{
		Complex c;
		c.real = real * b.real - image * b.image;
		c.image = image * b.real + real * b.image;
		return c;
	}

	double Model()
	{
		return sqrtf(real * real + image * image);
	}

	Complex Combine(  Complex add, Complex plus )
	{
		Complex temp = (*this)*plus ;
		temp.real += add.real;	
		temp.image += add.image;
		return temp;
	};
};    

//zero signal
#define CONST_C0 c0(0.05,0.05)
//excited signal
#define CONST_C1 c1(0.707,0.707)
//default nervus value
#define CONST_CN cn(0.1,0.1)

#define NERVUS_MODEL_LEVEL 0.1

#ifndef TRACE
#define TRACE printf
#endif

